package com.maas.util.mybatis.jpa.littlenb.common;

import com.littlenb.mybatisjpa.support.Certainty;

import java.util.HashSet;
import java.util.Set;

/**
 * 生成传参对象工具
 */
public class CertaintyUtil {

    /**
     *   生成传参对象
     * RcIssueType type = new RcIssueType();
     * type.setTypeNo(typeNo);
     * Certainty<RcIssueType> certainty  = CertaintyUtil.createCertainty(type,"typeNo");
     * @param obj
     * @param include
     * @param <T>
     * @return
     */
    public static  <T>  Certainty<T> createCertainty(T obj,String include ) {
        Set<String> includes = new HashSet<>();
        includes.add(include);
        Certainty<T>  certainty  =Certainty.includes(obj, includes);
        return certainty;
    }

    /**
     *   生成传参对象
     * RcIssueType type = new RcIssueType();
     * type.setTypeNo(typeNo);
     * Certainty<RcIssueType> certainty  = CertaintyUtil.createCertainty(type,{"typeNo"});
     * @param obj
     * @param include
     * @param <T>
     * @return
     */
    public static  <T>  Certainty<T> createCertainty(T obj,String[] includeArr) {
        Set<String> includes = new HashSet<>();
        if(includeArr!=null){
            for (int i = 0; i <includeArr.length ; i++) {
                includes.add(includeArr[i]);
            }
        }

        Certainty<T>  certainty  =Certainty.includes(obj, includes);
        return certainty;
    }



}
